package com.example.demo.system.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;

@Controller
public class LeaderboardController {

    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    // 当排行榜更新时通知所有客户端
    public void notifyLeaderboardUpdate(String leaderboardKey) {
        messagingTemplate.convertAndSend("/topic/leaderboard/" + leaderboardKey, "update");
    }
}

